package com.dingding.service.user.core.dao.impl;

import java.util.List;

import org.apache.log4j.Logger;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.dao.impl.BaseDaoImpl;
import com.dingding.common.core.beans.SystemMessage;
import com.dingding.service.user.core.dao.ISystemMessageDao;

/**
 * @Description: 系统消息
 * @author fengshuonan
 * @date 2016年7月22日11:15:14
 * 
 */
@Component("systemMessageDao")
public class SystemMessageDaoImpl extends BaseDaoImpl<SystemMessage> implements ISystemMessageDao {

	private Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * @Description:获取系统信息集合
	 * @param userId 用户id
	 * @param page 当前页码数
	 * @author fengshuonan
	 * @since 2.3.2
	 */
	@SuppressWarnings("unchecked")
	@Override
	@Transactional(readOnly = true)
	public List<SystemMessage> getSystemMsgList(String userId, Integer page) {

		List<SystemMessage> list = null;
		
		try {
			list = super.getCriteria().add(Restrictions.eq("messageStatus", 1))
					.addOrder(Order.desc("createTime")).list();
		} catch (Exception e) {
			log.error("获取系统信息列表的时候错误！SystemMessageDaoImpl : getSystemMsgList",e);
		}
		
		return list;
	}

}
